/*
 * @Author: 贺楠 1071780426@qq.com
 * @Date: 2024-09-13 14:23:50
 * @LastEditors: 贺楠 1071780426@qq.com
 * @LastEditTime: 2024-09-13 15:16:51
 * @FilePath: \monitoring_system\src\components\testMachineManage\testType\index.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import TableData from "@/components/public/el-table"; //主页面列表
import TableLyout from '@/components/commonPublic/tableLyout.vue'

import {
    getMachineTesttypeDictList,
} from "@/api/testMachineManage/request.js";

export default {
    props: [
        "dialogVisible",
    ],
    data() {
        return {
            visible: "",
            loading: false,
            tableData: [],
            isLock: false,
            dialogHeight: null,
            btnShow: true,
            WbsRow: null,
        };
    },
    components: {
        TableLyout,
        TableData,
    },
    watch: {
        dialogVisible: {
            handler(newVal) {
                if (newVal) {
                    this.visible = newVal;
                }
            },
            immediate: true,
        },
    },
    created() {
        window.addEventListener("resize", this.getHeight);
        this.getHeight();
    }, //获取页面高度自适应：

    destroyed() {
        window.removeEventListener("resize", this.getHeight);
        this.getHeight();
    },
    mounted() {

        this.yj_searchForm();
        this.getHeight();
    },
    methods: {
        getHeight() {
            var h = document.documentElement.clientHeight; //获取页面可见高度
            this.dialogHeight = h * 0.76 + "px";
        },
        closeDialog1() {
            this.$emit("close1");
        },

        // 获取列表数据
        yj_searchForm() {
            this.visible = true;
            this.load = true;
            getMachineTesttypeDictList({
            })
                .then((res) => {
                    if (res.errcode == 0) {
                        var data = res.data.Dictlist;
                        data.map(item => {
                            item['isShow'] = false;
                        })
                        this.tableData = data;
                    } else {
                        this.$message.error(res.msg);
                        this.loading = false;
                    }
                })
        },

        // 点击当前行变色
        handleCurrentChange(val) {
            this.WbsRow = val;
        },

        yj_saveForm() {

            var data = [];
            this.tableData.map(item => {
                if (item.isShow == true) {
                    data.push(item)
                }
            })

            this.$emit('getInfo', data)
            this.visible = false
            // } else {
            //     this.$message.error('请先选择工程部位');

            // }
        },

    },
};